<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>构造函数和原型对象this指向</title>
</head>

<body>
  <script>
    // ============================== 构造函数和原型对象this指向 ==============================

    // 1. 构造函数this指向 实例对象
    function Person(name, age) {
      this.name = name
    }

    // 2. 原型上的方法 this指向 ？
    Person.prototype.sayHi = function () {
      console.log('hi~')
      console.log(this)  // 
    }

    const zs = new Person('张三')
    zs.sayHi()
    const ls = new Person('李四')
    ls.sayHi()
  </script>
</body>

</html>